function totalMoney(n) {
  const fullWeeks = Math.floor(n / 7);
  const remainingDays = n % 7;
  // 计算完整周的总存款
  const fullWeeksSum = fullWeeks * 28 + (7 * fullWeeks * (fullWeeks - 1)) / 2;
  // 计算剩余天数的总存款
  const firstDayOfRemaining = fullWeeks + 1;
  const remainingSum =
    remainingDays * firstDayOfRemaining +
    (remainingDays * (remainingDays - 1)) / 2;
  return fullWeeksSum + remainingSum;
}
